<template>
  <div class="RulelibraryForm">
    <jxtech-basic-header :breadcrumbMappingUrl="RulelibraryIndexUrl">
      <template #extra>
        <jxtech-save-button @click='RulelibraryFormState.savehandler'></jxtech-save-button>
        <jxtech-back-button @click='RulelibraryFormState.backhandler'></jxtech-back-button>
      </template>
    </jxtech-basic-header>
    <rulelibrary-form-com ref="RulelibraryFormComRef" :rule-code="RulelibraryFormState.ruleCode" @add-success="RulelibraryFormState.onAddFormSuccess"
                          @update-success="RulelibraryFormState.onUpdateFormSuccess"></rulelibrary-form-com>
  </div>
</template>

<script lang="ts" setup>
import { reactive, ref } from "vue"
import { useRouter } from "vue-router"
import { RulelibraryIndexUrl } from "/@/views/personnel/mapping.json"
import RulelibraryFormCom from "./component/rulelibrary-form.vue"
import { redirectPath } from "/@/utils/router-kit"
const router = useRouter()
const RulelibraryFormComRef = ref()
const RulelibraryFormState = reactive({
  ruleCode: router.currentRoute.value.query.ruleCode as string,
  savehandler: () => RulelibraryFormComRef.value.save(),
  backhandler: () => router.push({ path: RulelibraryIndexUrl }),
  onAddFormSuccess: (formData: any) => {
    redirectPath(RulelibraryIndexUrl)
  },
  onUpdateFormSuccess: (formData: any) => {
    redirectPath(RulelibraryIndexUrl)
  }
})
</script>

<style lang="scss" scoped>
</style>
